package com.smart.test;

/**
 * <p><b>Description:</b>  TODO
 * <p><b>Company:</b>
 *
 * @author created by Jesse Xu at 9:50 on 2019/10/8
 * @version V0.1
 * @classNmae SequenceB
 */
public class SequenceB implements Sequence {
    private static ThreadLocal<Integer> numberContainer = new ThreadLocal<Integer>(){
        @Override
        protected Integer initialValue() {
            return 0;
        }
    };

    public int getNumber(int num) {
        numberContainer.set(numberContainer.get()+1);
        return numberContainer.get();
    }

    public static void main(String[] args) {
        Sequence sequence = new SequenceB();
        ClientThread client1 = new ClientThread(sequence);
        ClientThread client2 = new ClientThread(sequence);
        ClientThread client3 = new ClientThread(sequence);
        client1.start();
        client2.start();
        client3.start();
    }
}
